package hn.cch.web.request.validate;

import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;

public class ValidateUtil {


    public static ResponseEntity<String> handleValidate(BindingResult result) {
        StringBuilder builder = new StringBuilder();
        result.getFieldErrors().forEach((item) -> {
            builder.append(String.format("\t%s:%s\r\n", item.getField(), item.getDefaultMessage()));
        });
        return ResponseEntity.ok(String.format("%s:\r\n%s", "validate error", builder));
    }

}
